package com.example.modulethree.adapter

import android.content.Context
import android.view.View

import com.example.baselibrary.util.LKToastUtil
import com.example.modulethree.R
import com.example.modulethree.adapter.binder.KotlinTestAdapterBinder
import com.example.modulethree.adapter.delegate.KotlinTestAdapterDelegate
import com.example.mvp.adapter.BaseLibAdapter
import com.example.mvp.binder.BaseDataBinder


/**
 * 测试适配器操作处理类
 * Created by sun.li on 2018/6/28.
 *
 * @author sun.li
 */

class KotlinTestAdapter(context: Context, mList: List<String>) : BaseLibAdapter<KotlinTestAdapterDelegate, String>(context, mList) {

    override fun bindEvenListener(viewDelegate: KotlinTestAdapterDelegate, position: Int) {
        atiTextOnClickListener(viewDelegate, position)
    }

    private fun atiTextOnClickListener(viewDelegate: KotlinTestAdapterDelegate, position: Int) {
        viewDelegate.setOnClickListener(View.OnClickListener { v ->
            if (null != data) {
                val str = data[position]
                LKToastUtil.showToastShort(str)
                data[position] = str + "_" + v.id
                notifyDataSetChanged()
            }
        }, R.id.tv_ati_text)
    }

    override fun notifyView(viewDelegate: KotlinTestAdapterDelegate, position: Int) {
        //        viewDelegate.setText(getData().get(position));
    }

    override fun getDelegateClass(): Class<KotlinTestAdapterDelegate> {
        return KotlinTestAdapterDelegate::class.java
    }

    override fun getDataBinder(): BaseDataBinder<*, *> {
        return KotlinTestAdapterBinder()
    }
}